<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\JobCate;
use Dcat\Admin\Controllers\AdminController;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;

class JobCateController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new JobCate(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('name');
            $grid->column('enabled','是否显示')->switch();
        
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
            });
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new Jobcate(), function (Form $form) {
            $form->display('id');
            $form->text('name');
            $form->switch('enabled','是否显示')->default(1);
        });
    }


    public function getJobCate(){
        return \App\Models\Jobcate::getAllCate();
    }
}
